package com.example.senior_homework.di

import com.example.senior_homework.repository.api.SeniorUploadApi
import com.example.senior_homework.repository.web.AppGson
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

@Module
@InstallIn(SingletonComponent::class)
object WebModule {
    private val BASE_URL = "http://116.62.44.106:8080"

    @Provides
    fun provideRetrofit():Retrofit{
        val retrofit = Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create(AppGson.create()))
            .build()
        return retrofit
    }

    @Provides
    fun provideApiService(retrofit: Retrofit):SeniorUploadApi{
        return retrofit.create(SeniorUploadApi::class.java)
    }
}